package org.mozhu.mboot.core.data;

import org.mozhu.mboot.core.data.entity.IEntity;
import org.mozhu.mboot.core.data.filter.SearchFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;

import java.io.Serializable;
import java.util.List;

public interface IBaseService<T extends IEntity<ID>, ID extends Serializable> {

	List<T> findAll();

	List<T> findAll(Sort sort);

	List<T> findAllById(Iterable<ID> ids);

	List<T> findAllById(ID[] ids);

	List<T> saveAll(Iterable<T> entities);

	void flush();

	T saveAndFlush(T entity);

	void deleteInBatch(Iterable<T> entities);

	void deleteAllInBatch();

	T getOne(ID id);

	Page<T> findAll(Pageable pageable);

	T save(T entity);

	T findById(ID id);

	boolean existsById(ID id);

	long count();

	void deleteById(ID id);

	void delete(T entity);

	void deleteAll(Iterable<? extends T> entities);

	void deleteAll();

	T findOne(Specification<T> spec);

	List<T> findAll(Specification<T> spec);

	Page<T> findAll(Specification<T> spec, Pageable pageable);

	List<T> findAll(Specification<T> spec, Sort sort);

	long count(Specification<T> spec);

	void deleteInBatch(final ID[] ids);

	List<T> findAll(List<SearchFilter> searchFilters);

	Page<T> findAll(List<SearchFilter> searchFilters, Pageable pageable);

	Page<T> findAll(SearchFilter searchFilter, Pageable pageable);

	Page<T> findAll(Searchable searchable);

	long count(Searchable searchable);
}
